import java.util.Iterator;
import java.util.Vector;

import common.MySearchElement;
import common.Property;
import common.SkillManInstance;
import common.SkillManSchema;
import common.SkillManSearch;


public class Try2 {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception
	{
		SkillManSchema schema=new SkillManSchema();
		schema.setCWD(Property.skillMgmHome);
		schema.load();
		schema.addSkill("Programming", "Phython", "Knowledge of python programming language.");
		
		System.out.println();
		System.out.println();
		SkillManInstance i = new SkillManInstance(schema, "adolfo.owl");
		i.setCWD(Property.instances);
		i.loadDefault(Property.skillMgmHome+"default_instance.owl");
		i.setPropertyValue(SkillManInstance.foafNS+"Person", SkillManInstance.foafNS+"name" ,"Adolfo Hitler");
		i.addSkill("Java", 5);
		i.addSkill("Java", 2);
		i.addSkill("C_Socket", 4);
		System.out.println("Name: "+i.getProperyValue(SkillManInstance.foafNS+"Person", SkillManInstance.foafNS+"name"));
		System.out.println("Java skill level: "+i.getSkillLevel("Java"));
		
		System.out.println();
		System.out.println();
		SkillManInstance base = new SkillManInstance(schema, "slabodoschi.owl");
		base.setCWD(Property.instances);
		base.loadDefault(Property.skillMgmHome+"default_instance.owl");
		base.setPropertyValue(SkillManInstance.foafNS+"Person", SkillManInstance.foafNS+"name" ,"Jocopoco Majoco");
		base.addSkill("Java", 5);
		base.addSkill("C_Socket", 5);
		base.addSkill("Java_SWT", 3);		
		System.out.println("Name: "+base.getProperyValue(SkillManInstance.foafNS+"Person", SkillManInstance.foafNS+"name"));
		System.out.println("Java skill level: "+base.getSkillLevel("Java"));
		
//		System.out.println();
//		System.out.println("Qua finiscono le istanze");
//		System.out.println();
//		float perc=i.compareTo(base);
//		System.out.println("Le istanze sono uguali al "+perc+"%.");
		
		System.out.println();
		System.out.println();
		SkillManSearch search=new SkillManSearch(schema, base, Property.instances );
		search.loadFiles();
		System.out.println();
		System.out.println("--->qua nn arrivo");
		search.loadOnts();
		System.out.println();
		System.out.println("--->qua nn arrivo");
		search.compareToAll();
		
		System.out.println();
		System.out.println();
		System.out.println("Risultati");
		search.sortResults();
		System.out.println();
		System.out.println();
		System.out.println("Risultati");
		Vector<MySearchElement> v=search.getResults();
		Vector<common.MySkill> skills;
		for (int j = 0; j < v.size(); j++) {
			System.out.println((j+1)+".");
			System.out.println("\t"+v.get(j).inst.getProperyValue(SkillManInstance.foafNS+"Person", SkillManInstance.foafNS+"name"));
			System.out.println("-----------------------------");
			skills=v.get(j).inst.getSkills();
			System.out.println("\nEcco tutte le skill di "+v.get(j).inst.getProperyValue(SkillManInstance.foafNS+"Person", SkillManInstance.foafNS+"name"));
			for( int k=0; k<skills.size(); k++ )
			{
				System.out.println("Nome skill: "+skills.get(k).skill);
				System.out.println("Livello: "+skills.get(k).lvl+"\n");
			}
			System.out.println("-----------------------------");
			System.out.println("\tAffinity: "+v.get(j).affinity);
		}
		
		
		
		//i.store();
		//base.store();
		//schema.store();
	}

}
